package com.hs.common;

import java.io.PrintWriter;

import org.apache.derby.drda.NetworkServerControl;

import com.hs.Environment;

public class RunDrebyNetServer extends Thread{
	   static NetworkServerControl inst = null;
	   public RunDrebyNetServer(){
	   }
	    /** *//**
	     * 线程的run方法，它将和其他线程同时运行
	     */
	    public void run(){
//	        for(int i = 1; i <= 100; i++){
//	            try{
//	                Thread.sleep(100);
//	            } catch (InterruptedException ex){
//	                ex.printStackTrace();
//	            }
	    	while(true){
	    		try {
	    			System.out.println("1");
	    			if(inst == null){ 
	    				inst = new NetworkServerControl(Environment.PROP_BASE_DATABASE_IP, Environment.PROP_BASE_DATABASE_PORT);
	    				inst.ping();
	    			} 
				} catch (Exception e) { 
					try {
						inst.start(new PrintWriter(System.out));
					} catch (Exception e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
					e.printStackTrace();
				}
	    	}
//	        }
	    }
	    
	    public static void main(String[] args){
	    	RunDrebyNetServer server = new RunDrebyNetServer();
	    	server.start();
	    }

}
